package com.hjx.movie.core.system.controller.user;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hjx.movie.common.utils.Result;
import com.hjx.movie.core.system.service.admin.*;
import com.hjx.movie.core.system.service.user.IUserMovieService;

import com.hjx.movie.persistence.system.model.IvyMovie;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * <p>Title:</p>
 * <p>Description:</p>
 *
 * @author hjx
 * @date 2021/3/15 - 17:07
 */

@Slf4j
@RestController
@RequestMapping("userMovie")
public class UserMovieController {

    @Resource
    IMovieService movieService;
    @Resource
    ICinemaService cinemaService;
    @Resource
    IUserMovieService userMovieService;

    @GetMapping("/findAllByPage")
    public Result findAllMovie(@RequestParam(value="pageNum",defaultValue = "1")Long pageNum,
                               @RequestParam(value="pageSize",defaultValue = "10")Long pageSize,
                               @RequestParam(value="type",required = false,defaultValue = "")String type){
        Page<IvyMovie> page = new Page<>(pageNum,pageSize);
        return Result.success(movieService.findAllByPage(page,type));
    }
    //查询影院列表
    @GetMapping("/findAllCinema")
    public Result findAllCinemaData(){
        return Result.success(cinemaService.findAllCinema());
    }
    // 单查影院信息
    @GetMapping("/findCinemaById")
    public Result findCinemaById(@RequestParam("cid") Long cid){
        return Result.success(cinemaService.findCinemaById(cid));
    }


    @GetMapping("/findMovieShowInfoList")
    public Result findMovieShowInfoList(@RequestParam("cid") Long cid){
        Map<String,Object> map = new HashMap<>();
        map.put("cinemaInfo",cinemaService.findCinemaById(cid));
        map.put("movieShowInfo",userMovieService.findMovieShowInfoList(cid));
        return Result.success(map);
    }

    @GetMapping("/findSeatInfo")
    public Result findHallSeat(@RequestParam("msid") Long msid){
        return Result.success(userMovieService.findSeatInfo(msid));
    }



}
